package com.flow.asyncflow.core.utils.asyncFlowMonitor;

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.flow.asyncflow.core.entity.asyncFlowMonitor.*;
import com.flow.asyncflow.core.entity.log.asyncflowlog.AsyncFlowLogEntity;
import com.flow.asyncflow.core.entity.log.asyncflowlog.AsyncFlowNodeDetailLogEntity;
import com.flow.asyncflow.core.entity.log.asyncflowlog.AsyncFlowNodeLogEntity;
import com.flow.asyncflow.core.enums.ExecuteEnum;
import com.flow.asyncflow.core.utils.configuration.AsyncFlowConfiguration;
import com.flow.asyncflow.core.utils.dateutils.DateUtil;
import com.flow.asyncflow.core.utils.mongodb.MongoHelper;
import com.mongodb.BasicDBObject;
import com.mongodb.BasicDBObjectBuilder;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Filters;
import org.apache.commons.lang.StringUtils;
import org.bson.Document;
import org.bson.conversions.Bson;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class AsyncFlowMonitor {


    /**
     * 查询日志监控
     *
     * @param queryAsyncFlowLogRequest 请求
     * @return 返回
     */
    public AsyncFlowMonitorVo getAsyncFlowLogByPage(QueryAsyncFlowLogRequest queryAsyncFlowLogRequest) {
        AsyncFlowMonitorVo asyncFlowMonitorVo = new AsyncFlowMonitorVo();
        List<AsyncFlowLogVo> asyncFlowLogVoList = new ArrayList<>();
        int totalCount = 0;
        AsyncFlowConfiguration configInfo = new AsyncFlowConfiguration();
        MongoHelper<AsyncFlowLogEntity> mongoHelper;
        mongoHelper = new MongoHelper<>(configInfo.getMongoDBConfigStr(), configInfo.getMongoDBName(), configInfo.getMongoDBTableName());
        boolean eOrderService = false;
        if (configInfo.getAppUK().equals("tcgl.java.eorderservice.api")) {
            eOrderService = true;
        }
        Bson filer = null;

        if (StringUtils.isNotBlank(queryAsyncFlowLogRequest.getBusinessSerialId())) {

            if (eOrderService) {
                filer=Filters.eq("BusinessSerialId", queryAsyncFlowLogRequest.getBusinessSerialId());

            } else {
                filer = Filters.eq("businessSerialId", queryAsyncFlowLogRequest.getBusinessSerialId());
            }

        }
        if (StringUtils.isNotBlank(queryAsyncFlowLogRequest.getAsyncFlowName())) {
            if (filer != null) {
                if (eOrderService) {
                    filer = Filters.and(filer, Filters.eq("AsyncFlowModule", queryAsyncFlowLogRequest.getAsyncFlowName()));
                } else {
                    filer = Filters.and(filer, Filters.eq("asyncFlowModule", queryAsyncFlowLogRequest.getAsyncFlowName()));
                }
            } else {
                if (eOrderService) {
                    filer = Filters.eq("AsyncFlowModule", queryAsyncFlowLogRequest.getAsyncFlowName());
                } else {
                    filer = Filters.eq("asyncFlowModule", queryAsyncFlowLogRequest.getAsyncFlowName());
                }
            }

        }
        if (queryAsyncFlowLogRequest.getStartDate() != null) {
            if (filer != null) {
                if (eOrderService) {
                    filer = Filters.and(filer, Filters.gte("AsyncFlowDateTime", queryAsyncFlowLogRequest.getStartDate().toInstant(ZoneOffset.of("+0")).toEpochMilli()));
                } else {
                    filer = Filters.and(filer, Filters.gte("asyncFlowDateTime", queryAsyncFlowLogRequest.getStartDate().toInstant(ZoneOffset.of("+0")).toEpochMilli()));
                }
            } else {
                if (eOrderService) {
                    filer = Filters.gte("AsyncFlowDateTime", queryAsyncFlowLogRequest.getStartDate().toInstant(ZoneOffset.of("+0")).toEpochMilli());
                } else {
                    filer = Filters.gte("asyncFlowDateTime", queryAsyncFlowLogRequest.getStartDate().toInstant(ZoneOffset.of("+0")).toEpochMilli());
                }
            }

        }
        if (queryAsyncFlowLogRequest.getEndDate() != null) {
            if (filer != null) {

                if (eOrderService) {
                    filer = Filters.and(filer, Filters.lte("AsyncFlowDateTime", queryAsyncFlowLogRequest.getEndDate().toInstant(ZoneOffset.of("+0")).toEpochMilli()));
                } else {
                    filer = Filters.and(filer, Filters.lte("asyncFlowDateTime", queryAsyncFlowLogRequest.getEndDate().toInstant(ZoneOffset.of("+0")).toEpochMilli()));
                }
            } else {
                if (eOrderService) {
                    filer = Filters.lte("AsyncFlowDateTime", queryAsyncFlowLogRequest.getEndDate().toInstant(ZoneOffset.of("+0")).toEpochMilli());
                } else {
                    filer = Filters.lte("asyncFlowDateTime", queryAsyncFlowLogRequest.getEndDate().toInstant(ZoneOffset.of("+0")).toEpochMilli());
                }
            }
        }
        if (filer == null) {

            //2000-01-1 0:0:0  默认时间大于等于
            if (eOrderService) {
                filer = Filters.gte("AsyncFlowDateTime", 946656000000L);
            } else {
                filer = Filters.gte("asyncFlowDateTime", 946656000000L);
            }
        }

        try (MongoCursor<Document> documentMongoCursor = mongoHelper.findByPage(filer, queryAsyncFlowLogRequest.getPageNo(), queryAsyncFlowLogRequest.getPageSize())) {

            while (documentMongoCursor.hasNext()) {
                Document asyncFlowLogDocument = documentMongoCursor.next();
                String asyncFlowLogDocumentJson = com.mongodb.util.JSON.serialize(asyncFlowLogDocument);
                AsyncFlowLogEntity appInfo = JSONObject.parseObject(asyncFlowLogDocumentJson, AsyncFlowLogEntity.class);
                AsyncFlowLogVo asyncFlowLogVo;
                asyncFlowLogVo = getAsyncFlowNodeLogVo(appInfo);
                asyncFlowLogVoList.add(asyncFlowLogVo);
            }

        }
        totalCount = mongoHelper.getCount(filer);
        //if (!configInfo.getEvn().equals("test")) {
        //
        //
        //} else {
        //    //region 测试数据
        //    String json = "{\"AsyncFlowModule\":\"询占单-发送询位单\",\"AsyncFlowNodeLogEntityList\":[{\"Async\":false,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":1,\"LogFileName\":\"InquiryBaseValidator\",\"LogMethodName\":\"询位单详情基础验证\",\"LogMsg\":\"验证通过\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Validator.eb.inquiry.InquiryBaseValidator\",\"LogTime\":\"2022-01-12T13:43:07.313\",\"Status\":false,\"UseTimes\":0},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":100,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetTransportOrderInfo\",\"LogMethodName\":\"查询静态交通资源信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetTransportOrderInfo\",\"LogTime\":\"2022-01-12T13:43:07.338\",\"Status\":false,\"UseTimes\":24},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetOrderDetailInfo\",\"LogMethodName\":\"查询订单明细表信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoBase.GetOrderDetailInfo\",\"LogTime\":\"2022-01-12T13:43:07.344\",\"Status\":false,\"UseTimes\":31},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":100,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetTransportOrderPriceInfo\",\"LogMethodName\":\"采销交通价格体系\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetTransportOrderPriceInfo\",\"LogTime\":\"2022-01-12T13:43:07.346\",\"Status\":false,\"UseTimes\":32},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetSuppliersInquirynfo\",\"LogMethodName\":\"查询询位单信息表\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoExtend.GetSuppliersInquirynfo\",\"LogTime\":\"2022-01-12T13:43:07.346\",\"Status\":false,\"UseTimes\":22},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":100,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetSingleOrderInfo\",\"LogMethodName\":\"查询单产品资源\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetSingleOrderInfo\",\"LogTime\":\"2022-01-12T13:43:07.346\",\"Status\":false,\"UseTimes\":22},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetPackageResourcePriceInfo\",\"LogMethodName\":\"查询订单打包资源价格体系信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetPackageResourcePriceInfo\",\"LogTime\":\"2022-01-12T13:43:07.347\",\"Status\":false,\"UseTimes\":34},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetCarResourceOrderInfo\",\"LogMethodName\":\"查询单产品用车资源信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetCarResourceOrderInfo\",\"LogTime\":\"2022-01-12T13:43:07.354\",\"Status\":false,\"UseTimes\":30},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":100,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetOrderInfo\",\"LogMethodName\":\"查询订单主表信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoBase.GetOrderInfo\",\"LogTime\":\"2022-01-12T13:43:07.355\",\"Status\":false,\"UseTimes\":42},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetPackageResourceInfo\",\"LogMethodName\":\"查询订单打包资源信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetPackageResourceInfo\",\"LogTime\":\"2022-01-12T13:43:07.355\",\"Status\":false,\"UseTimes\":42},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":100,\"ExecuteEnumCode\":2,\"LogFileName\":\"GetCXHotelOrderInfo\",\"LogMethodName\":\"查询静态酒店资源信息\",\"LogMsg\":\"查询成功.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.GetData.pubgetdata.OrderInfoResource.GetCXHotelOrderInfo\",\"LogTime\":\"2022-01-12T13:43:07.355\",\"Status\":false,\"UseTimes\":31},{\"Async\":false,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[{\"LogDetailName\":\"数据库上下文\",\"LogFileName\":\"PubGetData\",\"Request\":\"{\\\"AsyncFlowModuleEnum\\\":\\\"Inquiry\\\",\\\"AsyncFlowNodeEnum\\\":\\\"SendInquiry\\\",\\\"BusinessSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"NodeRequest\\\":{\\\"BusinessMenId\\\":10217,\\\"Explain\\\":\\\"\\\",\\\"Operator\\\":\\\"刘叶香\\\",\\\"OperatorId\\\":\\\"51239\\\",\\\"OrderSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReqSubpathfrom\\\":3,\\\"ReqType\\\":1,\\\"Reqpathfrom\\\":1,\\\"ResourceType\\\":4,\\\"SubOrderId\\\":1780614},\\\"OperateName\\\":\\\"刘叶香\\\",\\\"OperateNo\\\":\\\"51239\\\",\\\"Params\\\":{},\\\"SourceDes\\\":\\\"开通审核\\\",\\\"requesterTime\\\":\\\"2022-01-12T13:43:07.313\\\"}\",\"Response\":\"{\\\"historyOrderSettlementDetailList\\\":[],\\\"inquiryPassengerIds\\\":[],\\\"inquiryResponse\\\":{\\\"inquiryOperatorResponse\\\":{\\\"IsSuccess\\\":false},\\\"inquiryTimeDetail\\\":{\\\"BillHistoryInfo\\\":{\\\"IPFRetentionTime\\\":0,\\\"IPFStatus\\\":0,\\\"Id\\\":0,\\\"PositionStatus\\\":0},\\\"IsSuccess\\\":false,\\\"OrderInfo\\\":{\\\"ProjectSource\\\":0},\\\"ProductModel\\\":{\\\"BusinessMenId\\\":0,\\\"CXHotelList\\\":[],\\\"CarList\\\":[],\\\"ExSingleOrderList\\\":[],\\\"ExtraList\\\":[],\\\"FlightList\\\":[],\\\"FlightResourcePriceList\\\":[],\\\"HotelPolicyId\\\":0,\\\"PackageResourceDetail\\\":{\\\"IsContainVisa\\\":false,\\\"ResourceId\\\":0},\\\"PorudctList\\\":[],\\\"ReceviceInformationList\\\":[],\\\"ResourceId\\\":0,\\\"ResourceOrderFlag\\\":0,\\\"SingleList\\\":[],\\\"SubOrderId\\\":0,\\\"SupplierId\\\":0,\\\"UnionTransportList\\\":[]},\\\"SupplierInfo\\\":{\\\"BusinessmenId\\\":0},\\\"TcInfo\\\":{},\\\"Tourists\\\":[]}},\\\"inquirySendRequest\\\":{\\\"BusinessMenId\\\":10217,\\\"Explain\\\":\\\"\\\",\\\"Operator\\\":\\\"刘叶香\\\",\\\"OperatorId\\\":\\\"51239\\\",\\\"OrderSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReqSubpathfrom\\\":3,\\\"ReqType\\\":1,\\\"Reqpathfrom\\\":1,\\\"ResourceType\\\":4,\\\"SubOrderId\\\":1780614},\\\"orderConfirmRequest\\\":{\\\"djeBOrderSendRequest\\\":{\\\"BusinessMenId\\\":0,\\\"ProjectSource\\\":0,\\\"ReqSubpathfrom\\\":0,\\\"ReqType\\\":0,\\\"Reqpathfrom\\\":0,\\\"ResourceType\\\":0,\\\"SubOrderId\\\":0},\\\"djebOrderReplyRequest\\\":{\\\"BusinessmenId\\\":0,\\\"ProjectSource\\\":0,\\\"ReplyStatus\\\":0,\\\"ReqType\\\":0,\\\"RetentionHour\\\":0,\\\"RetentionMin\\\":0},\\\"orderConfirmRealTimeInfoRequest\\\":{\\\"BusinessmenId\\\":0,\\\"LineProperty\\\":0,\\\"OrderConfirmType\\\":0,\\\"ProjectSource\\\":0,\\\"ReqType\\\":0,\\\"Reqpathfrom\\\":0,\\\"ResourceType\\\":0,\\\"SubOrderId\\\":0},\\\"replyRequest\\\":{\\\"BusinessmenId\\\":0,\\\"ProjectSource\\\":0,\\\"ReplyStatus\\\":0,\\\"ReqType\\\":0,\\\"ResourceType\\\":0,\\\"RetentionHour\\\":0,\\\"RetentionMin\\\":0,\\\"SingleType\\\":0,\\\"SubOrderId\\\":0}},\\\"orderConfirmResponse\\\":{\\\"dsfResponseBase\\\":{\\\"IsSuccess\\\":false},\\\"orderConfirmHistoryInfoResponse\\\":{\\\"BillId\\\":0,\\\"Status\\\":0},\\\"orderConfirmRealTimeInfoResponse\\\":{\\\"HistoryOrderRefundDetailList\\\":[],\\\"IsSuccess\\\":false,\\\"IsSummerCamp\\\":false,\\\"OrderAddressee\\\":{},\\\"OrderConfirmCustodians\\\":[],\\\"OrderConfirmPassenger\\\":{\\\"CurrentOrderPassengerList\\\":[],\\\"OldOrderPassengerList\\\":[]},\\\"OrderConfrimResource\\\":{\\\"OrderConfirmOtherResource\\\":{\\\"OrderConfirmFlightResourceList\\\":[],\\\"OrderConfirmHotelResourceList\\\":[],\\\"OrderConfirmTrainResourceList\\\":[]},\\\"OrderConfirmReferenceResource\\\":{\\\"OrderConfirmFlightResourceList\\\":[],\\\"OrderConfirmHotelResourceList\\\":[]},\\\"OrderConfirmRelateResource\\\":{\\\"OrderConfirmExtraChargeResourceList\\\":[],\\\"OrderConfirmSingleResourceList\\\":[]},\\\"OrderConfriCurrentmResource\\\":{\\\"OrderConfirmFlightResourceList\\\":[],\\\"OrderConfirmTrainResourceList\\\":[]}},\\\"OrderConfrimSettlement\\\":{\\\"OrderCurrentRefund\\\":{\\\"OrderConfirmRefundInfoList\\\":[],\\\"RefundRuleId\\\":0},\\\"OrderSettlementInfo\\\":{\\\"CurrentOrderSettlementDetailList\\\":[],\\\"OldOrderSettlementDetailList\\\":[]},\\\"OrderSettlementSummary\\\":{}},\\\"OrderStationInfo\\\":[]}},\\\"orderInfoBase\\\":{\\\"appointmentOrderEntity\\\":{\\\"changeValues\\\":{}},\\\"cLineOrderDetailEntity\\\":{\\\"ActConfigId\\\":0,\\\"ActivityId\\\":0,\\\"AssignType\\\":0,\\\"AssignWay\\\":3,\\\"BackMoneyAmount\\\":0.0,\\\"BusinessmenID\\\":10217,\\\"CCTIsJoinAnyPrivilege\\\":0,\\\"CODCompany\\\":321,\\\"ChangeOrderStatus\\\":4,\\\"ClientDemand\\\":\\\"\\\",\\\"CommentFee\\\":9.5,\\\"DestinationCityId\\\":\\\"133\\\",\\\"DestinationCityName\\\":\\\"三亚\\\",\\\"DestinationProvinceId\\\":\\\"9\\\",\\\"DeviceId\\\":\\\"\\\",\\\"FirstPayTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"Id\\\":2055226,\\\"Installment\\\":0,\\\"InvoiceStatus\\\":0,\\\"IsInsurance\\\":0,\\\"IsInvoiceType\\\":0,\\\"IsLogicDelete\\\":0,\\\"IsNegativeOrder\\\":0,\\\"IsOfflineIssue\\\":0,\\\"IsRequireOrder\\\":0,\\\"IsRichCustomer\\\":0,\\\"LineTitle\\\":\\\"测试\\\",\\\"MainTitle\\\":\\\"钻级评定国长当地固请勿下单下单无效3日跟团游\\\",\\\"OrderIp\\\":\\\"10.101.126.10\\\",\\\"OrderRemark\\\":\\\"\\\",\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"PayDeadline\\\":\\\"1900-01-01T00:00:00\\\",\\\"PositionType\\\":2,\\\"PreferentialType\\\":\\\"\\\",\\\"PrepaidAmount\\\":0.0,\\\"PricePlanId\\\":0,\\\"ProfitType\\\":1,\\\"ProfitValue\\\":0.0,\\\"RefId\\\":\\\"\\\",\\\"SellType\\\":-1,\\\"SessionId\\\":\\\"\\\",\\\"SettlementBillStatus\\\":0,\\\"StartAreaId\\\":\\\"0\\\",\\\"StartCityId\\\":\\\"321\\\",\\\"StartCityName\\\":\\\"上海\\\",\\\"StartCountryId\\\":\\\"1\\\",\\\"StartProvinceId\\\":\\\"25\\\",\\\"SupplierId\\\":0,\\\"SupplierName\\\":\\\"国长测试2\\\",\\\"TJEVersion\\\":\\\"A\\\",\\\"ThirdpartOrderType\\\":0,\\\"TouristGroupCity\\\":\\\"上海\\\",\\\"TravelCardPayAmount\\\":0.0,\\\"TravelGroupNo\\\":\\\"TC2201231052448C\\\",\\\"changeValues\\\":{},\\\"qdid\\\":\\\"\\\"},\\\"cLineOrderEntity\\\":{\\\"AllRePayAmount\\\":0.0,\\\"AlterDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"AlteredSerialId\\\":\\\"\\\",\\\"AssignAreaId\\\":0,\\\"AssignGroupId\\\":0,\\\"AssignTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"BranchCompanyId\\\":0,\\\"CancelReasonId\\\":0,\\\"ContactMail\\\":\\\"\\\",\\\"ContactMobile\\\":\\\"18550502316\\\",\\\"ContactName\\\":\\\"测试\\\",\\\"CreateName\\\":\\\"\\\",\\\"CustomerRemark\\\":\\\"\\\",\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"DataFlag\\\":1,\\\"DiscountAmount\\\":0.0,\\\"FirstCallDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"GainHandlerJobNum\\\":\\\"\\\",\\\"Id\\\":2055874,\\\"InsuranceAmount\\\":0.0,\\\"InsuranceReAmount\\\":0.0,\\\"IsFillInPassInfo\\\":0,\\\"IsPay\\\":0,\\\"IsTest\\\":1,\\\"IsWirlessDelete\\\":0,\\\"LeavTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"LineId\\\":1052448,\\\"LineProperty\\\":5,\\\"MemberId\\\":729815661,\\\"OpenId\\\":\\\"omUQJ0RP5J1P_lC35Le3RN7d_X9c\\\",\\\"OrderDate\\\":\\\"2022-01-12T13:42:32.360\\\",\\\"OrderFlag\\\":\\\"W\\\",\\\"OrderJobNumber\\\":\\\"\\\",\\\"OrderPlatform\\\":1074,\\\"OrderType\\\":0,\\\"PayDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"PaymentType\\\":0,\\\"PeopleCount\\\":2,\\\"PostAddress\\\":\\\"\\\",\\\"ProductSource\\\":3,\\\"ProductType\\\":1,\\\"ProjectSource\\\":2,\\\"RePayAmount\\\":0.0,\\\"ReconciliationFlag\\\":0,\\\"ReprocessHandlerJobNum\\\":\\\"\\\",\\\"ReturnDate\\\":\\\"2022-02-05T00:00:00\\\",\\\"SalesPrice\\\":44446.0,\\\"Serialid\\\":\\\"fd78851219f6886dfc\\\",\\\"SettlementPrice\\\":40000.0,\\\"SignedTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"SingleRoomNo\\\":0,\\\"SingleRoomPrice\\\":0.0,\\\"Sort\\\":0,\\\"StartDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"TheGroupJobNum\\\":\\\"\\\",\\\"ThirdPartySerialid\\\":\\\"\\\",\\\"changeValues\\\":{}},\\\"cLineOrderPassengerEntityList\\\":[],\\\"cLineOrderPriceEntityList\\\":[],\\\"clineOrderContactEntity\\\":{\\\"changeValues\\\":{}},\\\"clineOrderPartnerEntity\\\":{\\\"changeValues\\\":{}},\\\"orderIdentificationEntityList\\\":[],\\\"orderModuleStatisticsEntityList\\\":[],\\\"orderRegionInfoEntity\\\":{\\\"changeValues\\\":{}},\\\"orderStatusLogicEntity\\\":{\\\"changeValues\\\":{}}},\\\"orderInfoExtend\\\":{\\\"activityOrderScoreEntityList\\\":[],\\\"bankReductionVoucherEntity\\\":{\\\"changeValues\\\":{}},\\\"cLineVirtualSubsidyEntity\\\":{\\\"changeValues\\\":{}},\\\"contractRecEntity\\\":{\\\"changeValues\\\":{}},\\\"contractSubjectEntityList\\\":[],\\\"discountInfoEntityList\\\":[],\\\"financeOrderEntityList\\\":[],\\\"groupFlightInfoEntityList\\\":[],\\\"insuranceDetailEntityList\\\":[],\\\"insuranceDetailEntityMySqlList\\\":[],\\\"mailInfoEntityList\\\":[],\\\"orderDistributorEntity\\\":{\\\"changeValues\\\":{}},\\\"orderPrePaymentEntity\\\":{\\\"changeValues\\\":{}},\\\"payAgreementEntityList\\\":[],\\\"payTimesEntityList\\\":[],\\\"playAppointmentEntityList\\\":[],\\\"redPacketsEntityList\\\":[],\\\"shopOrderDetailEntity\\\":{\\\"changeValues\\\":{}},\\\"suppliersConfirmationEntityList\\\":[],\\\"suppliersInquiryEntityList\\\":[{\\\"ArrivedCity\\\":\\\"三亚\\\",\\\"BusinessmenID\\\":10217,\\\"CreateId\\\":\\\"51239\\\",\\\"CreateName\\\":\\\"刘叶香\\\",\\\"CreateTime\\\":\\\"2022-01-12T13:43:05.633\\\",\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"DataFlag\\\":1,\\\"IPFAdult\\\":0,\\\"IPFAllPersons\\\":2,\\\"IPFChild\\\":2,\\\"IPFConfirmationDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"IPFConfirmationId\\\":0,\\\"IPFConfirmationName\\\":\\\"\\\",\\\"IPFExplain\\\":\\\"\\\",\\\"IPFOperation\\\":0,\\\"IPFRemark\\\":\\\"\\\",\\\"IPFRetentionTime\\\":0,\\\"IPFStatus\\\":0,\\\"IPFType\\\":3,\\\"Id\\\":368953,\\\"InySerialId\\\":\\\"SI2485196\\\",\\\"IsNew\\\":1,\\\"LastOperator\\\":\\\"刘叶香\\\",\\\"LastOperatorId\\\":\\\"51239\\\",\\\"LastOperatorTime\\\":\\\"2022-01-12T13:43:05.633\\\",\\\"LineId\\\":1052448,\\\"LineTitle\\\":\\\"测试\\\",\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"PositionStatus\\\":0,\\\"ProjectSource\\\":2,\\\"ResourceExt\\\":\\\"\\\",\\\"ResourceId\\\":1052448,\\\"ResourceName\\\":\\\"测试\\\",\\\"ResourceType\\\":4,\\\"ResourceTypeName\\\":\\\"\\\",\\\"StartCity\\\":\\\"上海\\\",\\\"StartDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"SubOrderId\\\":1780614,\\\"SupplierId\\\":0,\\\"SupplierName\\\":\\\"国长测试2\\\",\\\"changeValues\\\":{}}],\\\"uploadRecEntityList\\\":[]},\\\"orderInfoRefund\\\":{\\\"carResourceOrderRefundEntityList\\\":[],\\\"djOrderRefundEntityList\\\":[],\\\"extraChargeRefundEntityList\\\":[],\\\"financeReturnPriceEntityList\\\":[],\\\"flightOrderRefundEntityList\\\":[],\\\"hotelOrderRefundEntityList\\\":[],\\\"internationalFlightOrderRefundEntityList\\\":[],\\\"internationalHotelOrderRefundEntityList\\\":[],\\\"orderAfterSaleServiceDetailEntityList\\\":[],\\\"orderAfterSaleServiceEntityList\\\":[],\\\"orderRefundSupplierEntityList\\\":[],\\\"orderRefundVerifyDetailsEntityList\\\":[],\\\"orderRefundVerifyEntityList\\\":[],\\\"packageResourceOrderRefundEntityList\\\":[],\\\"refundMethodEntityList\\\":[],\\\"singleResourceOrderRefundEntityList\\\":[],\\\"trainOrderRefundEntityList\\\":[],\\\"transportOrderRefundEntityList\\\":[]},\\\"orderInfoResource\\\":{\\\"carResourceOrderEntityList\\\":[],\\\"carResourceOrderPriceEntityList\\\":[],\\\"chunQiuOrderEntityList\\\":[],\\\"cxhotelOrderEntityList\\\":[],\\\"extraChargeOrderEntityList\\\":[],\\\"extraChargeOrderPriceEntityList\\\":[],\\\"flightOrderEntityList\\\":[],\\\"flightOrderPriceEntityList\\\":[],\\\"hotelOrderEntityList\\\":[],\\\"hotelOrderPriceEntityList\\\":[],\\\"interFlightOrderEntityList\\\":[],\\\"internationalFlightOrderPriceEntityList\\\":[],\\\"internationalHotelOrderEntityList\\\":[],\\\"orderResourceRelationShipEntityList\\\":[],\\\"packageResourceOrderEntityList\\\":[{\\\"BusinessmenID\\\":10217,\\\"ConfirmDealTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"ConfirmSendTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"CostConfirmationDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"CreateTime\\\":\\\"2022-01-12T13:42:32.373\\\",\\\"Currency\\\":\\\"CNY\\\",\\\"CurrencySettlementPrice\\\":40000.0,\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"DataFlag\\\":1,\\\"DepartureCityId\\\":\\\"321\\\",\\\"DepartureCityName\\\":\\\"上海\\\",\\\"DestinationCityId\\\":\\\"133\\\",\\\"DestinationCityName\\\":\\\"三亚\\\",\\\"EndDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"ExpiredDate\\\":\\\"1900-01-01T00:00:00\\\",\\\"GroundUseDays\\\":14,\\\"Id\\\":1780614,\\\"InquiryDealTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"InquirySendTime\\\":\\\"2022-01-12T13:43:05\\\",\\\"IsEbResource\\\":3,\\\"IsEditOrderGuide\\\":0,\\\"IsInvoiced\\\":0,\\\"LineResourceRelateProductId\\\":0,\\\"NoticeSubmitTime\\\":\\\"1900-01-01T00:00:00\\\",\\\"OpRemark\\\":\\\"\\\",\\\"OrderFlag\\\":1,\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"PackageOrderSerialid\\\":\\\"PA3001323\\\",\\\"PackageResourceId\\\":1052448,\\\"PackageResourceNo\\\":2,\\\"PackageType\\\":0,\\\"PickUpType\\\":4,\\\"ProjectSource\\\":2,\\\"Protocolnumber\\\":\\\"0\\\",\\\"PurchaseCompanyCode\\\":\\\"76\\\",\\\"PurchaseManager\\\":\\\"51239刘叶香\\\",\\\"Rebate\\\":0.0,\\\"RefundStatus\\\":0,\\\"ResourceName\\\":\\\"测试\\\",\\\"ResourceType\\\":3,\\\"SalesPrice\\\":44446.0,\\\"SettlementPrice\\\":40000.0,\\\"StartDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"StatementSerialId\\\":\\\"\\\",\\\"SupplierId\\\":10079,\\\"SupplierName\\\":\\\"国长测试2\\\",\\\"SupplierPurchasePrice\\\":40000.0,\\\"changeValues\\\":{}}],\\\"packageResourceOrderPriceEntityList\\\":[{\\\"BatchNumber\\\":\\\"\\\",\\\"CreateTime\\\":\\\"2022-01-12T13:42:32.377\\\",\\\"Currency\\\":\\\"CNY\\\",\\\"CurrencyPackageSettlementPrice\\\":20000.0,\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"CuttingPrepayPrice\\\":0.0,\\\"CuttingType\\\":3,\\\"DataFlag\\\":1,\\\"HardCuttingProtocolNo\\\":\\\"\\\",\\\"Id\\\":4540743,\\\"IsInvoiced\\\":0,\\\"OrderPassengerId\\\":6356994,\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"PackageOrderId\\\":1780614,\\\"PackageSalesPrice\\\":22223.0,\\\"PackageSettlementPrice\\\":20000.0,\\\"PassengerFlag\\\":0,\\\"PassengerType\\\":1,\\\"PriceType\\\":1,\\\"RefundStatus\\\":0,\\\"ResourceNum\\\":1,\\\"SeatClass\\\":\\\"\\\",\\\"SeatNo\\\":\\\"\\\",\\\"StatementSerialId\\\":\\\"\\\",\\\"SubOrderSerialid\\\":\\\"PA3001323\\\",\\\"TourismPriceId\\\":\\\"\\\",\\\"UseDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"changeValues\\\":{}},{\\\"BatchNumber\\\":\\\"\\\",\\\"CreateTime\\\":\\\"2022-01-12T13:42:32.377\\\",\\\"Currency\\\":\\\"CNY\\\",\\\"CurrencyPackageSettlementPrice\\\":20000.0,\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"CuttingPrepayPrice\\\":0.0,\\\"CuttingType\\\":3,\\\"DataFlag\\\":1,\\\"HardCuttingProtocolNo\\\":\\\"\\\",\\\"Id\\\":4540744,\\\"IsInvoiced\\\":0,\\\"OrderPassengerId\\\":6356995,\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"PackageOrderId\\\":1780614,\\\"PackageSalesPrice\\\":22223.0,\\\"PackageSettlementPrice\\\":20000.0,\\\"PassengerFlag\\\":0,\\\"PassengerType\\\":1,\\\"PriceType\\\":1,\\\"RefundStatus\\\":0,\\\"ResourceNum\\\":1,\\\"SeatClass\\\":\\\"\\\",\\\"SeatNo\\\":\\\"\\\",\\\"StatementSerialId\\\":\\\"\\\",\\\"SubOrderSerialid\\\":\\\"PA3001323\\\",\\\"TourismPriceId\\\":\\\"\\\",\\\"UseDate\\\":\\\"2022-01-23T00:00:00\\\",\\\"changeValues\\\":{}}],\\\"sceneryOrderEntityList\\\":[],\\\"sceneryOrderPriceEntityList\\\":[],\\\"seaTravelOrderEntityList\\\":[],\\\"seaTravelOrderPriceEntityList\\\":[],\\\"singleGetSiteEntityList\\\":[],\\\"singleResourceOrderEntityList\\\":[],\\\"singleResourceOrderPriceEntityList\\\":[],\\\"stationInfoEntityList\\\":[],\\\"trainOrderEntityList\\\":[],\\\"trainOrderPriceEntityList\\\":[],\\\"transportOrderEntityList\\\":[],\\\"transportOrderPriceEntityList\\\":[],\\\"visaResourceInfoEntityList\\\":[]},\\\"orderResourcePriceDetials\\\":[],\\\"refundConfirmationList\\\":[],\\\"relationSubOrderConfirmFlag\\\":0,\\\"relationSubOrderInquiryFlag\\\":0,\\\"subOrderFlag\\\":0,\\\"supplierBillOperatorEnum\\\":\\\"SendInquiry\\\",\\\"thisOrderResourceRelationShipEntityList\\\":[],\\\"travelOrderEntityList\\\":[]}\",\"Status\":true}],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":2,\"LogFileName\":\"PubGetData\",\"LogMethodName\":\"公共数据赋值\",\"LogMsg\":\"成功\",\"LogNodePath\":\"flow.PubGetData\",\"LogTime\":\"2022-01-12T13:43:07.357\",\"Status\":false,\"UseTimes\":2},{\"Async\":false,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":3,\"LogFileName\":\"InquirySend_ValidateIsNeed\",\"LogMethodName\":\"验证当前资源是否需要询位\",\"LogMsg\":\"地接资源不验证.\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Operator.eb.inquiry.send.InquirySend_ValidateIsNeed\",\"LogTime\":\"2022-01-12T13:43:07.364\",\"Status\":false,\"UseTimes\":7},{\"Async\":false,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[{\"LogDetailName\":\"查询询位单详情\",\"LogFileName\":\"InquirySend_BillDetailInfo\",\"Request\":\"{\\\"BillId\\\":0,\\\"BusinessMenId\\\":10217,\\\"Operator\\\":\\\"刘叶香\\\",\\\"OperatorId\\\":\\\"51239\\\",\\\"OrderSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReqSubpathfrom\\\":3,\\\"ResourceType\\\":4,\\\"SubOrderId\\\":1780614}\",\"Response\":\"{\\\"ErrorMessage\\\":\\\"成功\\\",\\\"IsSuccess\\\":true,\\\"OrderInfo\\\":{\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReturnDate\\\":\\\"2022-02-05\\\",\\\"StartDate\\\":\\\"2022-01-23\\\",\\\"TJEVersion\\\":\\\"A行程\\\"},\\\"ProductModel\\\":{\\\"BusinessMenId\\\":10217,\\\"CXHotelList\\\":[],\\\"CarList\\\":[],\\\"ExSingleOrderList\\\":[],\\\"ExtraList\\\":[],\\\"FlightList\\\":[],\\\"FlightResourcePriceList\\\":[],\\\"HotelPolicyId\\\":0,\\\"PackageResourceDetail\\\":{\\\"DepartureCityName\\\":\\\"上海\\\",\\\"DestinationCityName\\\":\\\"三亚\\\",\\\"EndDate\\\":\\\"2022-01-23\\\",\\\"IsContainVisa\\\":false,\\\"ResourceId\\\":1052448,\\\"ResourceName\\\":\\\"测试\\\",\\\"StartDate\\\":\\\"2022-01-23\\\"},\\\"PorudctList\\\":[{\\\"Currency\\\":\\\"CNY\\\",\\\"CuttingType\\\":\\\"现询\\\",\\\"PerPrice\\\":20000.0,\\\"PriceTypeName\\\":\\\"成人价\\\",\\\"ResourceCount\\\":2,\\\"ResourcePriceName\\\":\\\"测试\\\",\\\"TotalPrice\\\":40000.0}],\\\"ReceviceInformationList\\\":[],\\\"ResourceId\\\":1052448,\\\"ResourceName\\\":\\\"测试\\\",\\\"ResourceOrderFlag\\\":1,\\\"ResourceRemark\\\":\\\"\\\",\\\"SingleList\\\":[],\\\"SubOrderId\\\":1780614,\\\"SubOrderSerialId\\\":\\\"PA3001323\\\",\\\"SupplierId\\\":10079,\\\"SupplierName\\\":\\\"国长测试2\\\",\\\"UnionTransportList\\\":[]},\\\"SupplierInfo\\\":{\\\"BusinessmenId\\\":10217,\\\"ContactPerson\\\":\\\"联系人\\\",\\\"ContactPhone\\\":\\\"1111122223333\\\",\\\"Fax\\\":\\\"\\\",\\\"SupplierName\\\":\\\"国长测试2\\\"},\\\"TcInfo\\\":{\\\"ContactPhone\\\":\\\"4007777777-5\\\",\\\"ProductManager\\\":\\\"刘叶香\\\",\\\"SealUrl\\\":\\\"http://pic4.40017.cn/gny/line/2016/05/31/15/TCHKkh.png\\\",\\\"TcName\\\":\\\"嘉导国际旅行社（苏州）有限公司\\\"},\\\"Tourists\\\":[{\\\"TouristAge\\\":24,\\\"TouristBirth\\\":\\\"1997-04-08\\\",\\\"TouristCertNo\\\":\\\"J2223333\\\",\\\"TouristCertType\\\":\\\"护照\\\",\\\"TouristEnglishName\\\":\\\"JIU/JIU\\\",\\\"TouristName\\\":\\\"紧急\\\",\\\"TouristPhone\\\":\\\"\\\",\\\"TouristSex\\\":\\\"男\\\",\\\"TouristType\\\":\\\"成人\\\",\\\"TouristTypeInt\\\":0},{\\\"TouristAge\\\":31,\\\"TouristBirth\\\":\\\"1990-03-07\\\",\\\"TouristCertNo\\\":\\\"320102199003071343\\\",\\\"TouristCertType\\\":\\\"身份证\\\",\\\"TouristEnglishName\\\":\\\"TIAN/TIAN/\\\",\\\"TouristName\\\":\\\"天天\\\",\\\"TouristPhone\\\":\\\"18114739385\\\",\\\"TouristSex\\\":\\\"女\\\",\\\"TouristType\\\":\\\"成人\\\",\\\"TouristTypeInt\\\":0}]}\",\"Status\":true}],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":3,\"LogFileName\":\"InquirySend_BillDetailInfo\",\"LogMethodName\":\"获取询位单据详情\",\"LogMsg\":\"成功\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Operator.eb.inquiry.send.InquirySend_BillDetailInfo\",\"LogTime\":\"2022-01-12T13:43:07.998\",\"Status\":false,\"UseTimes\":634},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":3,\"LogFileName\":\"InquirySend_ModifySubOrderFlag\",\"LogMethodName\":\"更新子单状态\",\"LogMsg\":\"成功\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Operator.eb.inquiry.send.InquirySend_ModifySubOrderFlag\",\"LogTime\":\"2022-01-12T13:43:07.998\",\"Status\":false,\"UseTimes\":0},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":3,\"LogFileName\":\"InquirySend_SaveSupplierInquiryInfo\",\"LogMethodName\":\"保存询位单据信息\",\"LogMsg\":\"成功\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Operator.eb.inquiry.send.InquirySend_SaveSupplierInquiryInfo\",\"LogTime\":\"2022-01-12T13:43:08.036\",\"Status\":false,\"UseTimes\":38},{\"Async\":false,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[{\"LogDetailName\":\"TCTourismEOrder\",\"LogFileName\":\"BaseSave\",\"Request\":\"\\\"update top(1) PackageResourceOrder set  OrderFlag=1 ,InquirySendTime='2022-01-12 13:43:07',InquiryDealTime='1900-01-01',ExpiredDate='1900-01-01'  where Id=1780614; update top(1) OrderResourceRelationShip set  InquiryState=1,InquirySendDate='2022-01-12 13:43:07'  where Serialid='fd78851219f6886dfc' and SubOrderId=1780614 and DataFlag=1;\\\"\",\"Response\":\"\\\"TCTourismEOrder库插入【0】条数据；更新【2】条数据；\\\"\",\"Status\":true},{\"LogDetailName\":\"TCTourismEOrderServer\",\"LogFileName\":\"BaseSave\",\"Request\":\"\\\"UPDATE  TOP(1) SuppliersInquiry SET DataFlag = '0',IPFStatus = '2' WHERE Id = 368953;INSERT INTO SuppliersInquiry(ResourceName,SubOrderId,ProjectSource,IPFAllPersons,CreateId,IsNew,CustomerSerialid,PositionStatus,StartDate,InySerialId,LastOperator,IPFStatus,LineTitle,IPFChild,LineId,IPFAdult,LastOperatorTime,CreateTime,ResourceType,CreateName,ArrivedCity,IPFExplain,StartCity,IPFType,OrderSerialid,SupplierName,LastOperatorId,ResourceId,BusinessmenID) VALUES ('测试','1780614','2','2','51239','1','122981246','0','2022-01-23T00:00','SI9095389','刘叶香','0','测试','2','1052448','0','2022-01-12T13:43:08.004','2022-01-12T13:43:08.004','4','刘叶香','三亚','','上海','3','fd78851219f6886dfc','国长测试2','51239','1052448','10217');\\\"\",\"Response\":\"\\\"TCTourismEOrderServer库插入【1】条数据；更新【1】条数据；\\\"\",\"Status\":true}],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":4,\"LogFileName\":\"BaseSave\",\"LogMethodName\":\"保存\",\"LogMsg\":\"成功\",\"LogNodePath\":\"common.save.BaseSave\",\"LogTime\":\"2022-01-12T13:43:08.127\",\"Status\":false,\"UseTimes\":91},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[{\"LogDetailName\":\"发送询位单推送EB\",\"LogFileName\":\"InquirySend_NoticeEbAsync\",\"Request\":\"{\\\"BillInfoList\\\":[{\\\"AdultCount\\\":0,\\\"AllOccupiedStock\\\":0,\\\"AllStock\\\":0,\\\"ChildCount\\\":2,\\\"CustomerSerialId\\\":\\\"122981246\\\",\\\"EBAccountList\\\":[],\\\"GreateSupplierId\\\":10217,\\\"IsNeedSend\\\":false,\\\"OrderId\\\":1780614,\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"OriSupplierId\\\":0,\\\"ProductDate\\\":\\\"2022-01-23\\\",\\\"ProductId\\\":1052448,\\\"ProductTitle\\\":\\\"测试\\\",\\\"ProjectType\\\":3,\\\"RelateResourceType\\\":3,\\\"RelateSerialId\\\":\\\"368954\\\",\\\"RelateType\\\":2,\\\"ResourceId\\\":1052448,\\\"SupplierProductName\\\":\\\"测试\\\",\\\"ThisTimeOccupiedStock\\\":0,\\\"Type\\\":0,\\\"UsedStock\\\":0}],\\\"OperatorName\\\":\\\"刘叶香\\\",\\\"OperatorNo\\\":\\\"51239\\\",\\\"RelateType\\\":2}\",\"Response\":\"{\\\"IsSuccess\\\":true,\\\"ReponseMessage\\\":\\\"推送消息MQ成功，请等待发送\\\"}\",\"Status\":true}],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":6,\"LogFileName\":\"InquirySend_NoticeEbAsync\",\"LogMethodName\":\"询位发送后通知EB\",\"LogMsg\":\"成功\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Async.eb.inquiry.InquirySend_NoticeEbAsync\",\"LogTime\":\"2022-01-12T13:43:08.217\",\"Status\":false,\"UseTimes\":89},{\"Async\":true,\"AsyncFlowModuleEnum\":\"询占单\",\"AsyncFlowNodeDetailLogEntityList\":[],\"AsyncFlowNodeEnum\":\"发送询位单\",\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Code\":200,\"ExecuteEnumCode\":6,\"LogFileName\":\"InquirySend_SaveMongoDetailASync\",\"LogMethodName\":\"保存询位单Mongo详情\",\"LogMsg\":\"成功\",\"LogNodePath\":\"com.tcgl.eorderservice.orderflow.Async.eb.inquiry.InquirySend_SaveMongoDetailASync\",\"LogTime\":\"2022-01-12T13:43:08.434\",\"Status\":false,\"UseTimes\":306}],\"BusinessSerialId\":\"fd78851219f6886dfc\",\"Environments\":\"stage\",\"LogDateTime\":\"2022-01-12T13:43:08.457\",\"LogInfo\":\"【总耗时--813ms】【验证--0ms】【查询--43ms】【操作--679ms】【保存--91ms】【同步--0ms】\",\"LogTime\":\"2022-01-12 13:43:07\",\"Operator\":\"刘叶香-51239\",\"Request\":\"{\\\"AsyncFlowModuleEnum\\\":\\\"Inquiry\\\",\\\"AsyncFlowNodeEnum\\\":\\\"SendInquiry\\\",\\\"BusinessSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"NodeRequest\\\":{\\\"BusinessMenId\\\":10217,\\\"Explain\\\":\\\"\\\",\\\"Operator\\\":\\\"刘叶香\\\",\\\"OperatorId\\\":\\\"51239\\\",\\\"OrderSerialId\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReqSubpathfrom\\\":3,\\\"ReqType\\\":1,\\\"Reqpathfrom\\\":1,\\\"ResourceType\\\":4,\\\"SubOrderId\\\":1780614},\\\"OperateName\\\":\\\"刘叶香\\\",\\\"OperateNo\\\":\\\"51239\\\",\\\"Params\\\":{},\\\"SourceDes\\\":\\\"开通审核\\\",\\\"requesterTime\\\":\\\"2022-01-12T13:43:07.313\\\"}\",\"Response\":\"{\\\"Code\\\":200,\\\"Msg\\\":\\\"成功\\\",\\\"tRes\\\":{\\\"inquiryOperatorResponse\\\":{\\\"Code\\\":\\\"200\\\",\\\"IsSuccess\\\":true,\\\"Message\\\":\\\"成功\\\"},\\\"inquiryTimeDetail\\\":{\\\"ErrorMessage\\\":\\\"成功\\\",\\\"IsSuccess\\\":true,\\\"OpRemark\\\":\\\"\\\",\\\"OrderInfo\\\":{\\\"CustomerSerialid\\\":\\\"122981246\\\",\\\"OrderSerialid\\\":\\\"fd78851219f6886dfc\\\",\\\"ProjectSource\\\":2,\\\"ReturnDate\\\":\\\"2022-02-05\\\",\\\"StartDate\\\":\\\"2022-01-23\\\",\\\"TJEVersion\\\":\\\"A行程\\\"},\\\"ProductModel\\\":{\\\"BusinessMenId\\\":10217,\\\"CXHotelList\\\":[],\\\"CarList\\\":[],\\\"ExSingleOrderList\\\":[],\\\"ExtraList\\\":[],\\\"FlightList\\\":[],\\\"FlightResourcePriceList\\\":[],\\\"HotelPolicyId\\\":0,\\\"PackageResourceDetail\\\":{\\\"DepartureCityName\\\":\\\"上海\\\",\\\"DestinationCityName\\\":\\\"三亚\\\",\\\"EndDate\\\":\\\"2022-01-23\\\",\\\"IsContainVisa\\\":false,\\\"ResourceId\\\":1052448,\\\"ResourceName\\\":\\\"测试\\\",\\\"StartDate\\\":\\\"2022-01-23\\\"},\\\"PorudctList\\\":[{\\\"Currency\\\":\\\"CNY\\\",\\\"CuttingType\\\":\\\"现询\\\",\\\"PerPrice\\\":20000.0,\\\"PriceTypeName\\\":\\\"成人价\\\",\\\"ResourceCount\\\":2,\\\"ResourcePriceName\\\":\\\"测试\\\",\\\"TotalPrice\\\":40000.0}],\\\"ReceviceInformationList\\\":[],\\\"ResourceId\\\":1052448,\\\"ResourceName\\\":\\\"测试\\\",\\\"ResourceOrderFlag\\\":1,\\\"ResourceRemark\\\":\\\"\\\",\\\"SingleList\\\":[],\\\"SubOrderId\\\":1780614,\\\"SubOrderSerialId\\\":\\\"PA3001323\\\",\\\"SupplierId\\\":10079,\\\"SupplierName\\\":\\\"国长测试2\\\",\\\"UnionTransportList\\\":[]},\\\"SupplierInfo\\\":{\\\"BusinessmenId\\\":10217,\\\"ContactPerson\\\":\\\"联系人\\\",\\\"ContactPhone\\\":\\\"1111122223333\\\",\\\"Fax\\\":\\\"\\\",\\\"SupplierName\\\":\\\"国长测试2\\\"},\\\"TcInfo\\\":{\\\"ContactPhone\\\":\\\"4007777777-5\\\",\\\"ProductManager\\\":\\\"刘叶香\\\",\\\"SealUrl\\\":\\\"http://pic4.40017.cn/gny/line/2016/05/31/15/TCHKkh.png\\\",\\\"TcName\\\":\\\"嘉导国际旅行社（苏州）有限公司\\\"},\\\"Tourists\\\":[{\\\"TouristAge\\\":24,\\\"TouristBirth\\\":\\\"1997-04-08\\\",\\\"TouristCertNo\\\":\\\"J2223333\\\",\\\"TouristCertType\\\":\\\"护照\\\",\\\"TouristEnglishName\\\":\\\"JIU/JIU\\\",\\\"TouristName\\\":\\\"紧急\\\",\\\"TouristPhone\\\":\\\"\\\",\\\"TouristSex\\\":\\\"男\\\",\\\"TouristType\\\":\\\"成人\\\",\\\"TouristTypeInt\\\":0},{\\\"TouristAge\\\":31,\\\"TouristBirth\\\":\\\"1990-03-07\\\",\\\"TouristCertNo\\\":\\\"320102199003071343\\\",\\\"TouristCertType\\\":\\\"身份证\\\",\\\"TouristEnglishName\\\":\\\"TIAN/TIAN/\\\",\\\"TouristName\\\":\\\"天天\\\",\\\"TouristPhone\\\":\\\"18114739385\\\",\\\"TouristSex\\\":\\\"女\\\",\\\"TouristType\\\":\\\"成人\\\",\\\"TouristTypeInt\\\":0}]}}}\",\"SourceDes\":\"开通审核\",\"Status\":true,\"TrackGuid\":\"a8218035b0234af582ba8f5c68188079\",\"UseTime\":813}";
        //    AsyncFlowLogEntity appInfo = JSON.parseObject(json, AsyncFlowLogEntity.class);
        //    appInfo.setAsyncFlowDateTime(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
        //    appInfo.setLogTime(DateUtil.htFormat_yyyyMMddHH_mm_ss_SSS(LocalDateTime.now()));
        //    mongoHelper.insertOne(mongoHelper.toDocument(appInfo));
        //    AsyncFlowLogVo asyncFlowLogVo;
        //    asyncFlowLogVo = getAsyncFlowNodeLogVo(appInfo);
        //    asyncFlowLogVoList.add(asyncFlowLogVo);
        //    //endregion
        //}


        for (AsyncFlowLogVo asyncFlowLogVo : asyncFlowLogVoList) {
            asyncFlowLogVo.setLogTimeDate(cn.hutool.core.date.DateUtil.parse(asyncFlowLogVo.getLogTime()));
        }
        asyncFlowLogVoList = asyncFlowLogVoList.stream().sorted(Comparator.comparing(AsyncFlowLogVo::getLogTimeDate)).collect(Collectors.toList());
        asyncFlowMonitorVo.getAsyncFlowLogVoList().addAll(asyncFlowLogVoList);
        asyncFlowMonitorVo.setTotalCount(totalCount);
        return asyncFlowMonitorVo;
    }

    /**
     * MongoDB监控实体转化为页面显示实体
     *
     * @param asyncFlowLogEntity MongoDB实体
     * @return 页面显示实体
     */
    private AsyncFlowLogVo getAsyncFlowNodeLogVo(AsyncFlowLogEntity asyncFlowLogEntity) {
        AsyncFlowLogVo asyncFlowLogVo = new AsyncFlowLogVo();
        List<AsyncFlowNodeMonitorVo> asyncFlowNodeMonitorVoListOrderBy = new ArrayList<>();
        asyncFlowLogVo.setTrackGuid(asyncFlowLogEntity.getTrackGuid());
        asyncFlowLogVo.setBusinessSerialId(asyncFlowLogEntity.getBusinessSerialId());
        asyncFlowLogVo.setLogTime(asyncFlowLogEntity.getLogTime());
        asyncFlowLogVo.setAsyncFlowName(asyncFlowLogEntity.getAsyncFlowModule());
        asyncFlowLogVo.setUseTime(asyncFlowLogEntity.getUseTime() + "ms");
        asyncFlowLogVo.setResult(asyncFlowLogEntity.isStatus() ? "成功" : "失败");
        asyncFlowLogVo.setLogInfo(asyncFlowLogEntity.getLogInfo());
        asyncFlowLogVo.setOperator(asyncFlowLogEntity.getOperator());
        asyncFlowLogVo.setEvn(asyncFlowLogEntity.getEnvironments());
        asyncFlowLogVo.setSourceDes(asyncFlowLogEntity.getSourceDes());
        asyncFlowLogVo.setFlowRequestJsonStr(asyncFlowLogEntity.getRequest());
        asyncFlowLogVo.setFlowResponseJsonStr(asyncFlowLogEntity.getResponse());
        Map<Integer, List<AsyncFlowNodeLogEntity>> stringListMap = asyncFlowLogEntity.getAsyncFlowNodeLogEntityList().stream().collect(Collectors.groupingBy(AsyncFlowNodeLogEntity::getExecuteEnumCode));
        for (Map.Entry<Integer, List<AsyncFlowNodeLogEntity>> listEntry : stringListMap.entrySet()) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            if (listEntry.getKey() == 2 || listEntry.getKey() == 7) {
                asyncFlowNodeMonitorVo.setNodeTypeOrderBy(2);
                asyncFlowNodeMonitorVo.setNodeTypeName("查询");
            } else {
                asyncFlowNodeMonitorVo.setNodeTypeOrderBy(listEntry.getKey());
                asyncFlowNodeMonitorVo.setNodeTypeName(ExecuteEnum.getEnumByCode(listEntry.getKey()).getMsg());
            }


            for (AsyncFlowNodeLogEntity asyncFlowNodeLogEntity : listEntry.getValue()) {
                AsyncFlowNodeLogVo asyncFlowNodeLogVo = new AsyncFlowNodeLogVo();
                asyncFlowNodeLogVo.setBusinessSerialId(asyncFlowNodeLogEntity.getBusinessSerialId());
                asyncFlowNodeLogVo.setNodeInfo(asyncFlowNodeLogEntity.getLogMethodName() + "(" + asyncFlowNodeLogEntity.getLogFileName() + ")" + "-" + (asyncFlowNodeLogEntity.isAsync() ? "异步" : "同步"));
                asyncFlowNodeLogVo.setLogFileName(asyncFlowNodeLogEntity.getLogFileName());
                asyncFlowNodeLogVo.setLogTime(DateUtil.htFormat_yyyyMMddHH_mm_ss(asyncFlowNodeLogEntity.getLogTime()));
                asyncFlowNodeLogVo.setResultMsg(asyncFlowNodeLogEntity.getLogMsg());
                asyncFlowNodeLogVo.setExecuteEnumCode(asyncFlowNodeLogEntity.getExecuteEnumCode());
                asyncFlowNodeLogVo.setUseTime(asyncFlowNodeLogEntity.getUseTimes());
                asyncFlowNodeLogVo.setCode(asyncFlowNodeLogEntity.getCode());
                if (asyncFlowNodeLogVo.getCode() != 200) {
                    asyncFlowNodeMonitorVo.setErrorCount(asyncFlowNodeMonitorVo.getErrorCount() + 1);
                    //存在失败的 且当前值是false赋值
                    if (asyncFlowNodeMonitorVo.isErrorHidden()) {
                        asyncFlowNodeMonitorVo.setErrorHidden(false);
                    }
                }

                for (AsyncFlowNodeDetailLogEntity asyncFlowNodeDetailLogEntity : asyncFlowNodeLogEntity.getAsyncFlowNodeDetailLogEntityList()) {
                    AsyncFlowNodeDetailLogVo asyncFlowNodeDetailLogVo = new AsyncFlowNodeDetailLogVo();
                    asyncFlowNodeDetailLogVo.setLogDetailName(asyncFlowNodeDetailLogEntity.getLogDetailName());
                    asyncFlowNodeDetailLogVo.setNodeLogDetailVisible(false);
                    asyncFlowNodeDetailLogVo.setNodeRequestJsonStr(asyncFlowNodeDetailLogEntity.getRequest());
                    asyncFlowNodeDetailLogVo.setNodeResponseJsonStr(asyncFlowNodeDetailLogEntity.getResponse());

                    asyncFlowNodeLogVo.getAsyncFlowNodeDetailLogVoList().add(asyncFlowNodeDetailLogVo);
                }
                asyncFlowNodeMonitorVo.getAsyncFlowNodeLogVoList().add(asyncFlowNodeLogVo);
            }
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);

        }

        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 1)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(1);
            asyncFlowNodeMonitorVo.setNodeTypeName("验证");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }

        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 2)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(2);
            asyncFlowNodeMonitorVo.setNodeTypeName("查询");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }
        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 3)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(3);
            asyncFlowNodeMonitorVo.setNodeTypeName("操作");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }
        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 4)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(4);
            asyncFlowNodeMonitorVo.setNodeTypeName("保存");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }
        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 5)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(5);
            asyncFlowNodeMonitorVo.setNodeTypeName("同步");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }
        if (asyncFlowNodeMonitorVoListOrderBy.stream().noneMatch(c -> c.getNodeTypeOrderBy() == 6)) {
            AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVo = new AsyncFlowNodeMonitorVo();
            asyncFlowNodeMonitorVo.setNodeTypeOrderBy(6);
            asyncFlowNodeMonitorVo.setNodeTypeName("异步");
            asyncFlowNodeMonitorVo.setErrorCount(0);
            asyncFlowNodeMonitorVo.setErrorHidden(true);
            asyncFlowNodeMonitorVoListOrderBy.add(asyncFlowNodeMonitorVo);
        }
        asyncFlowLogVo.getAsyncFlowNodeMonitorVoList().addAll(asyncFlowNodeMonitorVoListOrderBy.stream().sorted(Comparator.comparing(AsyncFlowNodeMonitorVo::getNodeTypeOrderBy)).collect(Collectors.toList()));


        ////请求
        //AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVoReq = new AsyncFlowNodeMonitorVo();
        //asyncFlowNodeMonitorVoReq.setNodeTypeOrderBy(0);
        //asyncFlowNodeMonitorVoReq.setNodeTypeName("请求");
        //asyncFlowNodeMonitorVoReq.setFlowRequestJsonStr(asyncFlowLogEntity.getRequest());
        //asyncFlowLogVo.getAsyncFlowNodeMonitorVoList().add(0,asyncFlowNodeMonitorVoReq);
        ////返回
        //AsyncFlowNodeMonitorVo asyncFlowNodeMonitorVoRes = new AsyncFlowNodeMonitorVo();
        //asyncFlowNodeMonitorVoRes.setNodeTypeOrderBy(8);
        //asyncFlowNodeMonitorVoRes.setNodeTypeName("返回");
        //asyncFlowNodeMonitorVoRes.setFlowRequestJsonStr(asyncFlowLogEntity.getResponse());
        //asyncFlowLogVo.getAsyncFlowNodeMonitorVoList().add(asyncFlowNodeMonitorVoRes);

        return asyncFlowLogVo;
    }

}

